package 字节;

import java.util.PriorityQueue;
import java.util.Scanner;

/**
 * @author zhangmin
 * @create 2022-03-27 19:51
 */
public class 字节_0327_2 {
    public static void main(String[] args) {
        Scanner cin=new Scanner(System.in);
        int x=cin.nextInt(),n=cin.nextInt();
        PriorityQueue<Integer> pq=new PriorityQueue<>((a,b)->{
            return b-a;
        });
        if (x%2==0){
            pq.offer(x/2);
        }else {
            pq.offer(x);
        }
        for (int i = 1; i < n; i++) {
            int top=pq.poll();
            //只有当最大值为偶数时会对最大值有影响
            if (top%2==0){
                pq.offer((top/2)+1);
            }else {
                //当最大值为基数时，一定是将它+1为最大
                pq.offer(top+1);
            }
        }
        System.out.println(pq.peek());
    }
}
